<?php
	session_start();
	require('../Gen_Scripts/gen_functions.php');
	login();
	wipe_active();
	
	$query=
	"select t.game_no, t.game_day, t.close_poll_dt
	   from TOURNY t
	  where t.t_id = ".max_tid();
	if($result = mysql_query($query)){
		if($row = mysql_fetch_array($result)){
			$lst_game_no = $row['game_no'];
			$lst_game_day = $row['game_day'];
			$lst_close_poll = $row['close_poll_dt'];
		}
	}
	
	
	
?>
<form id="<?php echo $name2; ?>" method="post" action="Manage/t_add.php">
	<input type="hidden" name="poster" value="<?php echo $_SESSION['USERNUM']; ?>">
	<input type="hidden" name="post_dt" value="now()">
	<input type="hidden" name="vote" value="?">

	<div id="t1">
		<h1> Last &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; New </h1>
		<label>Game Number:</label>
		<input name="lst_game_no"    type="text" value="<?php echo $lst_game_no; ?>" />
		<input name="game_no"        type="text" value="<?php echo $game_no; ?>" />
		<label>Game Day:</label>
		<input name="lst_game_day"   type="text" value="<?php echo $lst_game_day; ?>" />
		<input name="game_day"       type="text" value="<?php echo $game_day; ?>" />
		<label>Close Poll:</label>
		<input name="lst_close_poll" type="text" value="<?php echo $lst_close_poll; ?>" />
		<input name="close_poll"     type="text" value="<?php echo $close_poll; ?>" />
	</div>
	
	<div id="games">
		<div id="gamea">
			<div id="title">
				<label>Game A </label>
				<select NAME="game_a">
				<?php 
					dblogin();
					$lista = "
						select gameid, game, owner
						from GAMES g";
					if($result = mysql_query($lista)){
						while($row = mysql_fetch_array($result)){
							echo '<option value="'.$row['gameid'].'"> '.$row['game'].'|'.player_name($row['owner']);
						}
					}
				?>
				</select>
			</div>
			<textarea name="gp_a"></textarea>
		</div>
		
		<div id="gameb">
			<div id="title">
				<label>Game B </label>
				<select NAME="game_b">
				<?php 
					dblogin();
					$lista = "
						select gameid, game, owner
						from GAMES g";
					if($result = mysql_query($lista)){
						while($row = mysql_fetch_array($result)){
							echo '<option value="'.$row['gameid'].'"> '.$row['game'].'|'.player_name($row['owner']);
						}
					}
				?>
				</select>
			</div>
			<textarea name="gp_b"></textarea>
		</div>
	</div>

	<textarea class="post" name="post"></textarea>
	
	
	<div id="buttons" class="edit">
		<input type="submit" value="submit" name="sub" />
		<input type="button" value="cancel" id="cancel" name="cancel"/>
	</div>
</form>
